import pygame


class Game:
    window = None
    try:
        chuangkou = open("data/窗口大小.txt", "r", encoding="utf-8")
        chuangkou_size = chuangkou.read()
        chuangkou.close()
        print(chuangkou_size)
        if str(chuangkou_size) == "全屏模式":
            quanping = False
        else:
            quanping = True
    except:
        quanping = True
    W = 1600
    H = 900
    bg = None
    kongge = False
    music = None
    index = 0
    yinyue = True
    tupian = None
    shengli = True
    player1 = None
    current_index = 0
    G = 0.5
    G_speed = 0
    speed = 4
    direction = None
    direction_W = False
    direction_A = False
    direction_S = False
    direction_D = False
    character_images = None
    current_images = None
    playerGroup = None
    zixinag_img = None
    player2 = None
    current_index2 = 0
    G2 = 0.5
    G_speed2 = 0
    speed2 = 4
    direction2 = None
    direction_W2 = False
    direction_A2 = False
    direction_S2 = False
    direction_D2 = False
    character_images2 = None
    current_images2 = None
    playerGroup2 = None
    fangkuai = False

    wall = None
    BLOCK_SIZE = 50
    MAP_HEIGHT = 18
    MAP_WIDTH = 32
    wall_list = []

    # 音效
    jump_music = None
    fashe_music = None
    bullet = None
    bullet_list = []
    run = True
    flag = True
    gem_number = None
    star = None
    # 传送门
    portal = None
    mini_portal1 = None
    mini_portal2 = None
    # 怪物属性
    monster = None
    monster_list = []
    monster_number = len(monster_list)

    monster1_star = None
    monster1_end = None

    monster2_star = None
    monster2_end = None

    monster3_star = None
    monster3_end = None

    monster4_star = None
    monster4_end = None

    monster5_star = None
    monster5_end = None

    monster6_star = None
    monster6_end = None

    levels = None
    level_text = None
    window_size = (1600, 900)

    def __init__(self):
        Game.window = None
        Game.shengli = True
        Game.W = 1600
        Game.H = 900
        Game.index = 0
        Game.player1 = None
        Game.current_index = 0
        Game.G = 0.5
        Game.G_speed = 0
        Game.speed = 4
        Game.direction = None
        Game.direction_W = False
        Game.direction_A = False
        Game.direction_S = False
        Game.direction_D = False
        Game.character_images = None
        Game.current_images = None
        Game.yinyue = True
        Game.playerGroup = pygame.sprite.Group()

        Game.wall = None
        Game.BLOCK_SIZE = 50
        Game.MAP_HEIGHT = 18
        Game.MAP_WIDTH = 32
        Game.wall_list = []

        Game.bullet = None
        Game.bullet_list = []

        # 初始化计数器
        count = 0
        Game.fangkuaixiaoshi = False
        # 遍历二维列表，找出所有的5并计数
        for row in Game.wall_list:
            for element in row:
                if element == 5:
                    count += 1

        for row in Game.wall_list:
            for element in row:
                if element == 6:
                    count += 1

        print(f"二维列表中值为5的元素数量为：{count}")

        Game.monster_list = [
        ]
        Game.monster1_star = None
        Game.monster1_end = None

        Game.monster2_star = None
        Game.monster2_end = None

        Game.monster3_star = None
        Game.monster3_end = None

        Game.monster4_star = None
        Game.monster4_end = None

        Game.monster5_star = None
        Game.monster5_end = None

        Game.gem_number = count


class Level:
    levels = None
